package com.kehutong.common.filter;

import java.util.List;

import org.coraframework.orm.jdbc.execute.DataFilter;
import org.coraframework.orm.jdbc.execute.ICondition;
import org.coraframework.orm.util.FilterBean;
import org.coraframework.util.Objects;

/**
 * <pre>部门权限</pre>
 * @author liuzhen
 *
 */
public class OfficeOnlyFilter implements DataFilter {

	@Override
	public String name() {
		return "3";
	}

	@Override
	public void filter(FilterBean bean, ICondition<?> condition) {
		if (Objects.isBlank(bean.getPartFieldName())) {
			return;
		}
		List<String> officeList = bean.getOfficeList();

		if (Objects.nonEmpty(officeList)) {
			condition.markBegin();
			for (String office : officeList) {
				condition.eq(bean.getPartFieldName(), office).or();
			}
			condition.markEnd();
		}
	}

	@Override
	public int level() {
		return 3;
	}


}
